package com.hzqy.web.ac.epg;
import com.hzqy.commons.utils.ExcelUtil;
import com.hzqy.commons.utils.ExcelUtil.MyEntry;
import com.hzqy.service.epg.AcStbUserVoteNumService;
import com.hzqy.web.vo.epg.AcStbUserVoteNumVo;
import com.hzqy.web.vo.epg.AcTicketNumVo;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/acStbUser")
public class AcStbUserVoteNumAction {
    @Resource
	private AcStbUserVoteNumService serviceAction;
	@RequestMapping("/acStbUserUpdateVoteNum")
	@ResponseBody
	public Object acProductUpdateAc(AcStbUserVoteNumVo aaVo){
		Map<String, Object> resultMap = new HashMap<String, Object>();
		int i=serviceAction.StbVoteNumInsert(aaVo);
		if(i > 0){
			resultMap.put("success", true);
			resultMap.put("result", "修改成功!");
		} else {
			resultMap.put("success", true);
			resultMap.put("result", "修改失败!flag=" + i);
		}
		return resultMap;
	}
	@RequestMapping("/acStbUserVoteNumAll")
	@ResponseBody
	public Object acProductSelectByReq(AcStbUserVoteNumVo aaVo,int page, int rows ){
		return serviceAction.selectAc(aaVo,page,rows);
	}
	@RequestMapping("/acStbUserVoteNumByReq")
	@ResponseBody
	public Object acProductSelectByReq(AcStbUserVoteNumVo aaVo){
		return serviceAction.selectById(aaVo);
	}
	//按导出当天
	@RequestMapping("/acStbUserVoteExcel")
	@ResponseBody
	public void acTicketExcel(AcStbUserVoteNumVo aaVo, HttpSession session, int page, int rows, HttpServletResponse response) throws IOException {
		Map<String,Object> ListMap = new HashMap<String, Object>();
    	ListMap = serviceAction.selectAc(aaVo,1,100000);
		List<AcStbUserVoteNumVo> data=(List<AcStbUserVoteNumVo>)ListMap.get("rows");
		List<MyEntry<String, String>> excelHeader=new ArrayList<MyEntry<String, String>>();
		excelHeader.add(new MyEntry<String,String>("f_asuv_serverid","业务帐号"));
		excelHeader.add(new MyEntry<String,String>("f_asuv_votenum","用户票数"));
		excelHeader.add(new MyEntry<String,String>("f_asuv_activityid","活动编号"));
        excelHeader.add(new MyEntry<String,String>("f_asuv_source","投票来源，1有料签到，2产品开通，3赠票卡"));
        excelHeader.add(new MyEntry<String,String>("f_asuv_memo","备注"));
        excelHeader.add(new MyEntry<String,String>("f_asuv_resolution","1代表标清，2代表高清"));
		excelHeader.add(new MyEntry<String,String>("f_asuv_cdate","的票时间"));
		boolean flag= ExcelUtil.generateExcel(data, excelHeader, response);
	}

}
